const SubmitWorkModel = require('../model/submitWork')
const tookit = require('../common/index')
const createToken = tookit.createToken
const sha1 = tookit.createHash
const verifyToken = tookit.verifyToken
const path = require('path')
const fs = require("fs")


//提交请求协议 将客户端发送过来的数据保存到数据库里
const submit = async function (ctx, next) {
    let res;
    try {
        let personEntity = new SubmitWorkModel(ctx.request.body);
        res = await personEntity.save();
    } catch (err) {
        console.log('err====',err);
        return
    }
    ctx.body = res;
}


//学生通知页面中获取作业发布数据
const getWorkData = async function (ctx, next) {
    let res = await SubmitWorkModel.find(ctx.title);
    console.log(res)
    ctx.body = {
        data: res,
        status: 'ok'
    }
}


module.exports = {
    submit,
    getWorkData
};